﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Projektet.Model
{
    abstract class Projectile
    {
        public Vector2 _position;
        protected Vector2 _velocity;
        protected Vector2 _gravity;
        protected Rectangle _hitRectangle;
        protected Rectangle _splashRectangle;
        public float _duration;
        public float _damage;

        public int _width;
        public int _height;

        public void Update(GameTime gameTime) 
        {
            _velocity += _gravity * gameTime.ElapsedGameTime.Milliseconds;
            _position += _velocity * gameTime.ElapsedGameTime.Milliseconds;
            _duration += gameTime.ElapsedGameTime.Milliseconds;
            _hitRectangle = new Rectangle((int)_position.X, (int)_position.Y, _width, _height);
            //_position += _velocity + _gravity;
            //Console.WriteLine(_position);
            //foreach(CombatUnit cU in unitList)
            //{
            //    if(_hitRectangle.Intersects(cU._unitRect))
            //    {
            //        cU.TakeDamage(_damage);
            //        Console.WriteLine(cU._health);
            //    }
            //}

            SpecificUpdate();
        }

        public virtual void DidHit() 
        {
            
        }

        public virtual void SpecificUpdate() 
        {
 
        }
    }
}
